/**
 * 
 */
package ua.at.tsvetkov.samizdat.adapters;

import ua.at.tsvetkov.samizdat.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * @author A.Tsvetkov 2011, http://tsvetkov.at.ua, al@ukr.net Адаптер основного меню.
 */
public class AdtAcMainMenu extends BaseAdapter {

	private LayoutInflater	mInflater;
	private Integer[]			menuIconsId	= { R.drawable.ic_ac_main_genres, R.drawable.ic_ac_main_authors, R.drawable.ic_ac_main_last_readed, R.drawable.ic_ac_main_loaded,
			R.drawable.ic_ac_main_favorite, R.drawable.ic_ac_main_favorite_authors, R.drawable.ic_ac_main_search_author };
	private String[]			menuText; 
//	{ "Жанры", "Авторы", "Читаю", "Загруженное", "Избранное", "Избранные авторы" };

	public AdtAcMainMenu(Context context) {
		mInflater = LayoutInflater.from(context);
		menuText =  new String[] {
				(String) context.getText(R.string.MENU_GENRE),
				(String) context.getText(R.string.MENU_AUTHORS),
				(String) context.getText(R.string.MENU_READ),
				(String) context.getText(R.string.MENU_LOADED),
				(String) context.getText(R.string.MENU_FAVORITE),
				(String) context.getText(R.string.MENU_FAVORITE_AUTHORS),
				(String) context.getText(R.string.MENU_SEARCH_AUTHOR)
				};
	}

	/*
	 * (non-Javadoc)
	 * @see android.widget.Adapter#getCount()
	 */
	@Override
	public int getCount() {
		return menuIconsId.length;
	}

	/*
	 * (non-Javadoc)
	 * @see android.widget.Adapter#getItem(int)
	 */
	@Override
	public Object getItem(int position) {
		return null;
	}

	/*
	 * (non-Javadoc)
	 * @see android.widget.Adapter#getItemId(int)
	 */
	@Override
	public long getItemId(int position) {
		return 0;
	}

	/*
	 * (non-Javadoc)
	 * @see android.widget.Adapter#getView(int, android.view.View, android.view.ViewGroup)
	 */
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		MenuViewHolder holder = new MenuViewHolder();
		if (convertView == null) {
			convertView = mInflater.inflate(R.layout.adt_ac_main, null);
			holder.menuIcon = (ImageView) convertView.findViewById(R.id.AdtAcMainMenuMenuIcon);
			holder.menuText = (TextView) convertView.findViewById(R.id.AdtAcMainMenuMenuText);
			convertView.setTag(holder);
		} else {
			holder = (MenuViewHolder) convertView.getTag();
		}

		holder.menuIcon.setImageResource(menuIconsId[position]);
		holder.menuText.setText(menuText[position]);
		return convertView;
	}

}

class MenuViewHolder {
	ImageView	menuIcon;
	TextView		menuText;
}
